Skip to content

[SANDBOX-1701] chore: upgrade to OCP 4.21 dependencies#522

Closed
metlos wants to merge 8 commits into
codeready-toolchain:masterfrom
metlos:upgrade-ocp-4.21
Closed

[SANDBOX-1701] chore: upgrade to OCP 4.21 dependencies#522
metlos wants to merge 8 commits into
codeready-toolchain:masterfrom
metlos:upgrade-ocp-4.21

Conversation

@metlos
Copy link
Copy Markdown
Contributor

@metlos metlos commented Mar 17, 2026

Update openshift/api and openshift/library-go to release-4.21, k8s.io deps to v0.34.1, controller-runtime to v0.22.0.

Adapt test FakeClient to work with real SSA support:

  • Remove Apply→Merge workaround (SSA is now natively supported)
  • Handle generation bump for SSA-created objects
  • Work around controller-runtime fake client bug where Update discards caller-set managedFields (needed for csaupgrade migration)
  • Add NewFakeClientWithManagedFields for tests that verify SSA managed fields behavior
  • Fix SSA migration test to provide APIVersion in ManagedFieldsEntry and use a non-empty Service spec for proper field tracking

Assisted-by: Claude Code

Summary by CodeRabbit

  • Chores
    • Updated core platform dependencies and multiple supporting libraries to newer stable versions for improved compatibility, security, and stability; refreshed indirect requirements and added a module replacement for alignment.
  • Documentation
    • Expanded developer-facing notes clarifying Server-Side Apply behavior and compatibility with the testing fake client.

Update openshift/api and openshift/library-go to release-4.21,
k8s.io deps to v0.34.3, controller-runtime to v0.22.5.

Adapt test FakeClient to work with real SSA support:
- Remove Apply→Merge workaround (SSA is now natively supported)
- Handle generation bump for SSA-created objects
- Work around controller-runtime fake client bug where Update
  discards caller-set managedFields (needed for csaupgrade migration)
- Add NewFakeClientWithManagedFields for tests that verify SSA
  managed fields behavior
- Fix SSA migration test to provide APIVersion in ManagedFieldsEntry
  and use a non-empty Service spec for proper field tracking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 17, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Updated Go module dependency versions (Kubernetes, OpenShift, and various libraries), added a module replace directive, and expanded an inline SSA-compatibility comment in the test client’s Patch method. No exported API changes.

Changes

Cohort / File(s) Summary
Dependency Updates
go.mod
Upgraded OpenShift libs to release-4.21 pseudo-versions, bumped k8s.io/{api,apimachinery,client-go} to v0.34.1, updated multiple Kubernetes-adjacent libraries (e.g., k8s.io/utils, go-restful/v3, fsnotify, fxamacker/cbor, gnostic-models, modern-go/reflect2), switched YAML/structured-merge-diff stack (go.yaml.in/yaml/v2,v3, sigs.k8s.io/structured-merge-diff/v6, sigs.k8s.io/yaml), and added replace github.com/codeready-toolchain/api => github.com/metlos/api ....
Test Client Documentation
pkg/test/client.go
Expanded the Patch fake-client SSA-compatibility comment to reference additional controller-runtime issue/PR context; no behavioral or API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: upgrading to OCP 4.21 dependencies, which is reflected in both the go.mod and test client updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@go.mod`:
- Around line 126-127: The go.mod contains a replace directive "replace
github.com/codeready-toolchain/api => github.com/metlos/api
v0.0.0-20260311111036-f94bc6f41690" that points to a personal fork; either
remove this replace or replace it with the official module, and if keeping it
temporarily, add an inline comment and a linked issue/PR that documents why the
fork is required and the plan to revert (e.g., add a TODO with issue/PR number
and an expiration rationale next to the replace directive), and update the
commit message to explain the temporary nature and timeline for removal.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ef7f35c2-5aec-455e-9990-5b5b276c6e61

📥 Commits

Reviewing files that changed from the base of the PR and between 52d9242 and bbfe574.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • go.mod
  • pkg/client/ssa_client_test.go
  • pkg/test/client.go

Comment thread go.mod Outdated
Comment on lines +126 to +127

replace github.com/codeready-toolchain/api => github.com/metlos/api v0.0.0-20260311111036-f94bc6f41690
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if there's an open PR in the codeready-toolchain/api repo that this fork might be based on
echo "Checking the fork commit referenced in the replace directive..."
echo "Fork: github.com/metlos/api @ v0.0.0-20260311111036-f94bc6f41690"
echo ""
echo "This appears to be a personal fork. Verify that:"
echo "1. The required API changes are being upstreamed"
echo "2. This replace directive will be removed before merge or shortly after"
echo ""
# Check if the main API repo has recent activity that might include these changes
gh api repos/codeready-toolchain/api/pulls --jq '.[0:5] | .[] | {number, title, state, user: .user.login}' 2>/dev/null || echo "Could not fetch PR info"

Repository: codeready-toolchain/toolchain-common

Length of output: 516


🏁 Script executed:

# Check the actual content of go.mod at the specified lines
cat -n go.mod | sed -n '120,135p'

Repository: codeready-toolchain/toolchain-common

Length of output: 502


🏁 Script executed:

# Check git history for this change
git log --oneline -20 -- go.mod

Repository: codeready-toolchain/toolchain-common

Length of output: 127


🏁 Script executed:

# Look for any recent commits that added this replace directive
git log -p -S "metlos/api" -- go.mod | head -100

Repository: codeready-toolchain/toolchain-common

Length of output: 62


🏁 Script executed:

# Get the full commit message and diff context
git show bbfe574 --stat | head -50

Repository: codeready-toolchain/toolchain-common

Length of output: 2799


🏁 Script executed:

# Check if there's any branch information or PR context
git log bbfe574 -1 --format=fuller

Repository: codeready-toolchain/toolchain-common

Length of output: 1104


🏁 Script executed:

# Check if there are any CHANGELOG, PR templates, or issue references
git log bbfe574 -1 --format=%B

Repository: codeready-toolchain/toolchain-common

Length of output: 814


🏁 Script executed:

# Check if the replace directive is still in the current HEAD
git rev-parse HEAD

Repository: codeready-toolchain/toolchain-common

Length of output: 120


🏁 Script executed:

# Verify this is the actual current state
cat go.mod | grep -A 2 -B 2 "replace github.com/codeready-toolchain/api"

Repository: codeready-toolchain/toolchain-common

Length of output: 185


🏁 Script executed:

# Check if there are any recent commits after this that might address it
git log --oneline -10 -- go.mod

Repository: codeready-toolchain/toolchain-common

Length of output: 127


Remove or document the replace directive for the personal fork of codeready-toolchain/api.

The replace directive points to a personal fork (github.com/metlos/api) instead of the official repository. While this was included in the OCP 4.21 dependency upgrade commit, there is no explanation in the commit message for why this fork is necessary. This creates maintenance and security risks:

  • Personal forks can be deleted, archived, or diverge from the official repo
  • It creates an undocumented dependency that complicates dependency management
  • It may cause resolution issues in CI/CD pipelines or for downstream consumers

Either document the temporary nature of this fork and the plan to remove it, or replace it with the official github.com/codeready-toolchain/api repository.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go.mod` around lines 126 - 127, The go.mod contains a replace directive
"replace github.com/codeready-toolchain/api => github.com/metlos/api
v0.0.0-20260311111036-f94bc6f41690" that points to a personal fork; either
remove this replace or replace it with the official module, and if keeping it
temporarily, add an inline comment and a linked issue/PR that documents why the
fork is required and the plan to revert (e.g., add a TODO with issue/PR number
and an expiration rationale next to the replace directive), and update the
commit message to explain the temporary nature and timeline for removal.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
go.mod (1)

126-127: ⚠️ Potential issue | 🟠 Major

The personal fork replace directive persists.

The replace directive still points to a personal fork (github.com/metlos/api), though updated to a newer commit. The concerns raised in the previous review comment regarding maintainability, security, and dependency resolution remain applicable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go.mod` around lines 126 - 127, Remove the personal-fork replace directive
that references "github.com/metlos/api" in go.mod and instead point the module
to the official upstream module (restore or add a versioned requirement for
"github.com/codeready-toolchain/api" with a proper semantic version or a vetted
commit pseudo-version); if a forked module is absolutely required for a
temporary fix, replace it with an organizationally-approved fork and document
the reason in a comment, and ensure the replace line referencing
"github.com/metlos/api" is deleted or replaced accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@go.mod`:
- Around line 126-127: Remove the personal-fork replace directive that
references "github.com/metlos/api" in go.mod and instead point the module to the
official upstream module (restore or add a versioned requirement for
"github.com/codeready-toolchain/api" with a proper semantic version or a vetted
commit pseudo-version); if a forked module is absolutely required for a
temporary fix, replace it with an organizationally-approved fork and document
the reason in a comment, and ensure the replace line referencing
"github.com/metlos/api" is deleted or replaced accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fc918ed0-04a8-425d-8a72-c1b9acbe4598

📥 Commits

Reviewing files that changed from the base of the PR and between bbfe574 and f8505ba.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod

Comment thread pkg/test/client.go Outdated
}

return cl.Client.Update(ctx, obj, opts...)
// Work around a controller-runtime fake client bug where Update unconditionally
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, is there a ling to an issue we could track?

and the associated changes to the SSA handling in
the test client.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
go.mod (1)

127-127: ⚠️ Potential issue | 🔴 Critical

Remove the forbidden module replacement before merge (CI blocker).

Line 127 replaces github.com/codeready-toolchain/api with a personal fork, and ci-check-gomod is already failing on this exact rule. This blocks merge and introduces avoidable supply-chain/maintenance risk.

Proposed fix
-replace github.com/codeready-toolchain/api => github.com/metlos/api v0.0.0-20260327105121-b79d7632f264
#!/bin/bash
# Verify the blocker is removed from go.mod
rg -n '^replace\s+github\.com/codeready-toolchain/api\s*=>' go.mod || true

# Show effective replacement (should print nothing after fix)
go list -m all 2>/dev/null | rg -n 'github.com/codeready-toolchain/api.*=>'

As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go.mod` at line 127, Remove the forbidden replace directive that swaps
github.com/codeready-toolchain/api to the personal fork (the replace statement
currently added in go.mod); revert to the upstream module by deleting that
replace line and, if a specific version is required, add an approved semantic
version for github.com/codeready-toolchain/api instead of a fork so
ci-check-gomod passes and supply-chain risk is removed (this touches the replace
directive for github.com/codeready-toolchain/api in go.mod and will resolve the
ci-check-gomod failure).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@go.mod`:
- Line 127: Remove the forbidden replace directive that swaps
github.com/codeready-toolchain/api to the personal fork (the replace statement
currently added in go.mod); revert to the upstream module by deleting that
replace line and, if a specific version is required, add an approved semantic
version for github.com/codeready-toolchain/api instead of a fork so
ci-check-gomod passes and supply-chain risk is removed (this touches the replace
directive for github.com/codeready-toolchain/api in go.mod and will resolve the
ci-check-gomod failure).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: e71aade4-2340-457d-93a6-5bef26176a33

📥 Commits

Reviewing files that changed from the base of the PR and between f8505ba and 9f768c4.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod
  • pkg/test/client.go
✅ Files skipped from review due to trivial changes (1)
  • pkg/test/client.go

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
go.mod (1)

128-128: ⚠️ Potential issue | 🟠 Major

Replace to personal fork remains a supply-chain/maintenance risk.

Line 128 still replaces github.com/codeready-toolchain/api with github.com/metlos/api. If this is temporary, add an inline TODO with linked tracking issue/PR and removal plan; otherwise switch back to the official module before merge.

#!/bin/bash
# Check replace directive and whether it is documented inline
cat -n go.mod | sed -n '122,132p'
rg -n 'replace github.com/codeready-toolchain/api' go.mod
rg -n 'TODO|FIXME|tracking issue|remove.*replace|metlos/api' go.mod

As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go.mod` at line 128, The go.mod replace directive swapping
github.com/codeready-toolchain/api to github.com/metlos/api is a
supply-chain/maintenance risk; either revert the replace to the official module
or, if it must remain temporarily, annotate the replace line in go.mod with an
inline TODO that references a tracking issue/PR number and a clear removal plan
and deadline. Update the replace directive comment to include the tracking
issue/PR link and expected removal date, and ensure CI/PR description documents
why the fork is used; if reverting, remove the replace directive and run go mod
tidy to restore the canonical dependency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@go.mod`:
- Around line 22-25: Update the controller-runtime module version in go.mod:
change the existing declaration sigs.k8s.io/controller-runtime v0.21.0 to
v0.22.0 so it matches the Kubernetes modules (k8s.io/api, k8s.io/apimachinery,
k8s.io/client-go at v0.34.1); run go mod tidy afterwards to resolve transitive
dependencies and rebuild to ensure there are no API incompatibilities in your
controller code.

---

Duplicate comments:
In `@go.mod`:
- Line 128: The go.mod replace directive swapping
github.com/codeready-toolchain/api to github.com/metlos/api is a
supply-chain/maintenance risk; either revert the replace to the official module
or, if it must remain temporarily, annotate the replace line in go.mod with an
inline TODO that references a tracking issue/PR number and a clear removal plan
and deadline. Update the replace directive comment to include the tracking
issue/PR link and expected removal date, and ensure CI/PR description documents
why the fork is used; if reverting, remove the replace directive and run go mod
tidy to restore the canonical dependency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 223b70c2-90d3-4bab-8917-75818e93c58c

📥 Commits

Reviewing files that changed from the base of the PR and between 9f768c4 and 409388b.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod

Comment thread go.mod
Comment on lines +22 to 25
k8s.io/api v0.34.1
k8s.io/apimachinery v0.34.1
k8s.io/client-go v0.34.1
sigs.k8s.io/controller-runtime v0.21.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify current version skew in go.mod
rg -n '^\s*(k8s\.io/(api|apimachinery|client-go|kubectl|cli-runtime|apiextensions-apiserver)|sigs\.k8s\.io/controller-runtime)\s+v' go.mod

Repository: codeready-toolchain/toolchain-common

Length of output: 1821


🌐 Web query:

What Kubernetes minor version compatibility is documented for sigs.k8s.io/controller-runtime v0.21.0 and v0.22.0?

💡 Result:

  • controller-runtime v0.21.0: documented as aligned with k8s.io/client-go v0.33.x, which corresponds to Kubernetes v1.33.x. [1][2]
  • controller-runtime v0.22.0: documented as aligned with k8s.io/client-go v0.34.x, which corresponds to Kubernetes v1.34.x. [1][2]

Sources:
[1] controller-runtime repo README “Compatibility” table (CR v0.21 → client-go v0.33; CR v0.22 → client-go v0.34) (github.com)
[2] client-go INSTALL.md: v0.x.y tags correspond to Kubernetes v1.x.y (chromium.googlesource.com)

Citations:


Upgrade sigs.k8s.io/controller-runtime to v0.22.0 to match Kubernetes v0.34.1 modules.

Line 25 keeps sigs.k8s.io/controller-runtime v0.21.0 while Lines 22-24 use Kubernetes modules at v0.34.1. According to controller-runtime's official compatibility matrix, v0.21.0 is designed for k8s v0.33.x, while v0.22.0 pairs with v0.34.x. This version skew causes API/type incompatibilities in controller code and violates maintainability requirements.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go.mod` around lines 22 - 25, Update the controller-runtime module version in
go.mod: change the existing declaration sigs.k8s.io/controller-runtime v0.21.0
to v0.22.0 so it matches the Kubernetes modules (k8s.io/api,
k8s.io/apimachinery, k8s.io/client-go at v0.34.1); run go mod tidy afterwards to
resolve transitive dependencies and rebuild to ensure there are no API
incompatibilities in your controller code.

… for openshift api 4.21 + codeready-toolchain/api
@metlos metlos force-pushed the upgrade-ocp-4.21 branch from 409388b to 04ab229 Compare April 9, 2026 17:43
@sonarqubecloud
Copy link
Copy Markdown

@metlos
Copy link
Copy Markdown
Contributor Author

metlos commented Apr 16, 2026

Postponed until operator-sdk is upgradable, too.

@metlos metlos closed this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants